//
//  LXOrderSumView.m
//  跑跑快销
//
//  Created by linxian on 14-5-8.
//  Copyright (c) 2014年 ylife. All rights reserved.
//
#define ViewHeight                      [UIScreen mainScreen].bounds.size.height
#define searchBarH                      40
#define TitleWidth 320 / 3
#define LableHeight 50
#import "LXOrderSumView.h"

@implementation LXOrderSumView
@synthesize osumTableView, addGoodBtn, sumPriceLab;
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self createAddBtn];
        [self createTableView];
        [self createTitleView];
        [self createLable];
        
    }
    return self;
}


- (void)createTitleView
{
    int navBarY,navBarH;
    
    if (ISDEVICE7) {
        navBarY = 0;
        navBarH = 64;
    }else{
        navBarY = 20;
        navBarH = 44;
    }
    _navBarH = navBarH;
    _navBarY = navBarY;
    
    UILabel *lable1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, TitleWidth, 60)];
    lable1.text = @"货品名称";
    lable1.textAlignment = NSTextAlignmentCenter;
    lable1.layer.borderWidth = 0.25;
    lable1.layer.borderColor = [UIColor blackColor].CGColor;
    [self addSubview:lable1];
    
    UILabel *lable2 = [[UILabel alloc]initWithFrame:CGRectMake(TitleWidth , 0, TitleWidth, 60)];
    lable2.text = @"数量";
    lable2.textAlignment = NSTextAlignmentCenter;
    lable2.layer.borderWidth = 0.25;
    lable2.layer.borderColor = [UIColor blackColor].CGColor;
    [self addSubview:lable2];
    
    UILabel *lable3 = [[UILabel alloc]initWithFrame:CGRectMake(TitleWidth * 2, 0, TitleWidth, 60)];
    lable3.text = @"金额";
    lable3.textAlignment = NSTextAlignmentCenter;
    lable3.layer.borderWidth = 0.25;
    lable3.layer.borderColor = [UIColor blackColor].CGColor;
    [self addSubview:lable3];
}

- (void)createTableView
{
    osumTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 60, 320, PHONESIZEHEIGHT - STARTY - LableHeight*2 - 60)];
    NSLog(@"%f",self.frame.size.height);
    [osumTableView registerClass:[LXSumFormCell class] forCellReuseIdentifier:@"LXFormCell"];
    [osumTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    osumTableView.showsVerticalScrollIndicator = NO;
    [osumTableView setBounces:NO];
    [self addSubview:osumTableView];
}

- (void)createLable
{
    UILabel *lable1 = [[UILabel alloc]initWithFrame:CGRectMake(0, PHONESIZEHEIGHT - STARTY - LableHeight*2, 160, LableHeight)];
    lable1.text = @"合计(元)";
    lable1.textAlignment = NSTextAlignmentCenter;
    lable1.layer.borderWidth = 0.25;
    lable1.layer.borderColor = [UIColor blackColor].CGColor;
    [self addSubview:lable1];
    
    sumPriceLab = [[UILabel alloc]initWithFrame:CGRectMake(160 , PHONESIZEHEIGHT - STARTY - LableHeight*2, 160, LableHeight)];
    sumPriceLab.textAlignment = NSTextAlignmentCenter;
    sumPriceLab.layer.borderWidth = 0.25;
    sumPriceLab.layer.borderColor = [UIColor blackColor].CGColor;
    [self addSubview:sumPriceLab];
    
}

-(void)createAddBtn
{
    addGoodBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, PHONESIZEHEIGHT - STARTY - LableHeight, 320, LableHeight)];
    addGoodBtn.backgroundColor = [UIColor blueColor];
    [addGoodBtn setTitle:@"     添加商品到订单" forState:UIControlStateNormal];
    [self addSubview:addGoodBtn];
    
    UIImageView *iconImg = [[UIImageView alloc] initWithFrame:CGRectMake(70, LableHeight/4.0, LableHeight/2.0, LableHeight/2.0)];
    iconImg.backgroundColor = [UIColor lightGrayColor];
    [addGoodBtn addSubview:iconImg];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
